package org.csu.jpetmanage.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.csu.jpetmanage.mapper.CategoryMapper;
import org.csu.jpetmanage.model.Category;
import org.csu.jpetmanage.service.CategoryService;
import org.springframework.stereotype.Service;

//申明此处为service
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {

    @Override
    public Page<Category> listData(Category category, long current, long size) {
        QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
        if (null != category.getCatid()) {
            queryWrapper.eq("catid", category.getCatid());
            queryWrapper.like("name", category.getName());
            queryWrapper.like("descn", category.getDescn());
        }

        return baseMapper.selectPage(new Page<>(current, size), queryWrapper);
    }
}
